<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button></button>
    <span></span>
    <script>
        // 1.创建ajax对象
        let ajax = new XMLHttpRequest();

        //2.配置ajax请求
        ajax.open('get', 'http://localhost:3000/index');

        //3.发送ajax请求
        ajax.send();

        //4.等待响应，响应完成接受的结果
        ajax.onreadystatechange = function(){
            if(ajax.readyState == 4 && ajax.status == 200){
                console.log(ajax.responseText);
                let data = JSON.parse(ajax.responseText)
                
            }
        }

    </script>
</body>

</html>